import request from '@/utils/request'

export default{
    getOrganizerList(searchModel){
        return request({
            url:'organizers',
            method:'get',
            params:{
                name: searchModel.name,
                pageNo: searchModel.pageNo,
                pageSize: searchModel.pageSize
            }
        });
    },
    deleteImage(fileName) {
        return request({
            url: `/files/${fileName}`,   // 调用后端的删除接口
            method: 'delete',
        });
    },
    addOrganizer(organizer){
        return request({
            url: '/organizers',
            method: 'post',
            data: organizer
        });
    },
    updateOrganizer(organizer){
        return request({
            url: '/organizers',
            method: 'put',
            data: organizer
        });
    },
    getOrganizerById(id){
        return request({
            url: `/organizers/${id}`,
            method: 'get',
        });
    },
    saveOrganizer(organizer){
        if(organizer.id == null || organizer.id == undefined){
            return this.addOrganizer(organizer);
        }else{
            console.log(organizer)
            return this.updateOrganizer(organizer);
        }
    },
    deleteOrganizerById(id){
        return request({
            url: `/users/${id}`,
            method: 'delete',
        });
    },
}